import SecurityService from 'tomtaw-authority'

// const host = configUrl.frontEndUrl
// const logoutUrl = host
// const clientid = 'eworld.spa.imagecloud'
export default class SecurityServiceWrapper {
  constructor () {
    const that = this
    if(process.env.NODE_ENV === 'development')
    {
      that.ss = new SecurityService({
        subdir: window.Config.subdir, // 虚拟目录路径
        scope: 'openid profile api-operate api-ability api-cloudpacs api-miis api-pis api-nmis api-epis api-ewcss api-calling api-dms api-imaging api-archive api-asis api-telemed api-teach api-idcas api-quality api-imgbd api-asis-admin api-pacs-common',
        oidcSettings: { accessTokenExpiringNotificationTime: 60 },
        clearStorageBeforeUnload: false,

      })
    }else
    {
      that.ss = new SecurityService({
        scope: 'openid profile api-cloudpacs api-telemed api-idcas api-operate api-reserve api-quality api-archive api-structure api-document api-im api-pis api-ability api-datamining api-dms api-imaging api-search api-ewcss',
        subdir: window.Config.subdir, // 虚拟目录路径
        oidcSettings: { accessTokenExpiringNotificationTime: 60 },
        clearStorageBeforeUnload: false,

      })
    }
    
  }

  // 获取权限
  async getRole () {
    return this.ss.getRole()
  }

  // 登录
  signIn () {
    return this.ss.signIn()
  }

  // 退出
  signOut () {
    return this.ss.signOut()
  }

  // 删除用户
  removeUser () {
    return this.ss.removeUser()
  }
}
